package org.dh2580.dev.tools.util;

import java.util.Objects;

/**
 * 布尔工具类
 *
 * @Author: hao.deng
 * @Date: 2018/11/29-上午10:20
 */
public final class BoolUtil {
    private BoolUtil() {
    }

    public static boolean allTrue(boolean... args) {
        Objects.requireNonNull(args, "args cannot be null");
        for (boolean arg : args) {
            if (!arg) {
                return false;
            }
        }
        return true;
    }

    public static boolean anyTrue(boolean... args) {
        Objects.requireNonNull(args, "args cannot be null");
        for (boolean arg : args) {
            if (arg) {
                return true;
            }
        }
        return false;
    }

    public static boolean nonTrue(boolean... args) {
        return !anyTrue(args);
    }

    public static boolean allFalse(boolean... args) {
        Objects.requireNonNull(args, "args cannot be null");
        for (boolean arg : args) {
            if (arg) {
                return false;
            }
        }
        return true;
    }

    public static boolean anyFalse(boolean... args) {
        Objects.requireNonNull(args, "args cannot be null");
        for (boolean arg : args) {
            if (!arg) {
                return true;
            }
        }
        return false;
    }

    public static boolean nonFalse(boolean... args) {
        return !anyFalse(args);
    }
}
